package com.android.music.prolyric;


import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.app.TabActivity;

import android.app.ActionBar.Tab;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;

@SuppressWarnings("deprecation")
public class Library extends TabActivity
{
	int colorTab,imgBgr;
	private SharedPreferences prefs;
	private TabHost tabHost;	
	private int version;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.library);
        
        tabHost = (TabHost)findViewById(android.R.id.tabhost);
        prefs = getSharedPreferences("libraryColor", MODE_PRIVATE);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        version = Build.VERSION.SDK_INT;
        
        colorTab= (int) prefs.getInt("tabcolor",0xffffffff);
        imgBgr=(int) prefs.getInt("lbgr",R.drawable.girl);
        tabHost.setBackgroundDrawable(getResources().getDrawable(imgBgr));
       
        addTab();
                
    }
    
    private void addTab()
    {
    	TabHost tab = getTabHost();        
        tab.addTab(createTab(LibraryAllSong.class,"AllSong", "ALL SONG"));
        tab.addTab(createTab(LibraryAlbum.class,"Albums", "ALBUMS"));
        tab.addTab(createTab(LibraryArtist.class,"Artists", "ARTISTS"));
        if(version>Build.VERSION_CODES.FROYO)
        	tab.addTab(createTab(LibraryFolder.class,"Folder", "FOLDERS"));              
       
    }
    
    private TabSpec createTab(final Class<?> intentClass, final String tag,final String title)
    {
        final Intent intent = new Intent().setClass(this, intentClass);
        final View tab = LayoutInflater.from(getTabHost().getContext()).inflate(R.layout.tab_indicator_holo, null);
        ((TextView)tab.findViewById(R.id.tabTitle)).setText(title);        
        ((TextView)tab.findViewById(R.id.tabTitle)).setTextColor(colorTab);
        return getTabHost().newTabSpec(tag).setIndicator(tab).setContent(intent);
    }
    

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_library, menu);
        return true;
    }   
     
    
}


